package com.mia.props.client.fx;

import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;

public enum ParticleHandler {
   INSTANCE;

   Minecraft mc = Minecraft.getMinecraft();
   EffectRenderer renderer;

   private ParticleHandler() {
      this.renderer = this.mc.effectRenderer;
   }

   public void renderParticle(EntityFX particule) {
      if (this.mc != null) {
         if (this.renderer != null) {
            int i = this.mc.gameSettings.particleSetting;
            if (i <= 1) {
               this.renderer.addEffect(particule);
            }
         }
      }
   }

   public void renderParticle(String name, World world, double x, double y, double z, double velX, double velY, double velZ, float size) {
      this.renderParticle(this.getFXByName(name, world, x, y, z, velX, velY, velZ, size));
   }

   public EntityFX getFXByName(String name, World world, double x, double y, double z, double velX, double velY, double velZ, float size) {
      if (name.equals("flame")) {
         return new EntityCustomFlameFX(world, x, y, z, velX, velY, velZ, size);
      } else if (name.equals("bubble")) {
         return new EntityCustomBubbleFX(world, x, y, z, velX, velY, velZ, size);
      } else if (name.equals("magic")) {
         return new EntityCustomMagicFX(world, x, y, z, velX, velY, velZ, size);
      } else if (name.equals("rain")) {
         return new EntityCustomRainFX(world, x, y, z, size);
      } else {
         return name.equals("smoke") ? new EntityCustomSmokeFX(world, x, y, z, velX, velY, velZ, size) : null;
      }
   }
}
